package org.toves.checklua.ast;

import org.toves.checklua.scan.Token;

public class Complaint {
	public static final int ERROR = 10;
	public static final int WARNING = 5;

	public static Complaint createError(Token token, String message) {
		return new Complaint(ERROR, token, message);
	}
	
	public static Complaint createWarning(Token token, String message) {
		return new Complaint(WARNING, token, message);
	}
	
	private int level;
	private Token token;
	private String message;
	
	private Complaint(int level, Token token, String message) {
		this.level = level;
		this.token = token;
		this.message = message;
	}
	
	public int getLevel() {
		return level;
	}
	
	public Token getRepresentativeToken() {
		return token;
	}
	
	public String getMessage() {
		return message;
	}
	
	public String toString() {
		return token.getLine() + "." + token.getColumn()
			+ " " + token.getText(10) + ": " + message;
	}
}
